<template>
  <div class="Login">
    <h1>This is an Login page</h1>
    <input type="text" name="" id="" v-model="username" placeholder="请输入昵称" />
    <button @click="handelEntry">进入</button>
  </div>
</template>
<script>
export default {
  name: 'Login',
  data() {
    return {
      username: '',
    }
  },
  methods: {
    handelEntry() {
      const username = this.username.trim()
      console.log(this.username)
      if (username != '') {
        localStorage.setItem('username', username)
        this.$router.push('/')
      } else {
        alert('请输入昵称')
      }
    },
  },
}
</script>
